package com.huayi.test.springbootcomm.service.impl;

import com.huayi.test.springbootcomm.dao.TblUserMapper;
import com.huayi.test.springbootcomm.entity.TblUser;
import com.huayi.test.springbootcomm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("userService")
public class UserServiceImpl implements UserService {

    private final TblUserMapper tblUserMapper;

    @Autowired
    public UserServiceImpl(TblUserMapper tblUserMapper) {
        this.tblUserMapper = tblUserMapper;
    }

    @Override
    public void save(TblUser tblUser) {
        int count = tblUserMapper.insert(tblUser);

    }

    @Override
    public void delteOne(TblUser tblUser) {
        int count = tblUserMapper.deleteByPrimaryKey(tblUser.getId());

    }

    @Override
    public TblUser queryOne(Integer id) {
       TblUser tblUser = tblUserMapper.selectByPrimaryKey(id);
        return tblUser;
    }

    @Override
    public void updateOne(TblUser tblUser) {
        int count = tblUserMapper.updateByPrimaryKey(tblUser);
    }
}
